<?php
// 本类由系统自动生成，仅供测试用途
class LinkAction extends Action {
     public function index(){
		R('Index/indexpic');
		$this->hot();
		$this->school();
		$this->outside();
        $this->display();
    }
	private function hot(){
		$model=M('article');
		$cond['type']='友情链接';
		$list=$model->where($cond)->order('istop desc')->limit('0,4')->select();
		$this->assign('list',$list);
	}
	private function school(){
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='友情链接';
		$cond['image']='校内链接';
		$index=$article->where($cond)->count();
		$Page = new Page($index,2);//实例化分页类传入总记录数和每页显示的记录数
		$Page->setConfig('theme','%upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end%');
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list1',$list);
		$this->assign('page1',$show);//赋值分页输出
	}
	private function outside(){
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='友情链接';
		$cond['image']='校外天地';
		$index=$article->where($cond)->count();
		$Page = new Page($index,3);//实例化分页类传入总记录数和每页显示的记录数
		$Page->setConfig('theme','%upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end%');
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list2',$list);
		$this->assign('page2',$show);//赋值分页输出
	}
}
?>